home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / comm / comm1 / klrkcmsr.lha / amiconsasc.c < prev    next >
C/C++ Source or Header  |  1994-10-11  |  5KB  |  206 lines

  1. #include <exec/exec.h>
  2. #include <dos/dos.h>
  3. #include <libraries/dos.h>
  4. #include <devices/timer.h>
  5. #include <proto/intuition.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include "sc:ae/doorheader.h"
  9. #include <proto/exec.h>
  10. #include <proto/dos.h>
  11. #include <string.h>
  12. #include "amiconsasc_protos.h"
  13. //#include <functions.h>
  14. #define FOREVER for(;;)
  15. #define SM sendmessage
  16. #define HK hotkey
  17. #define FHK Fhotkey
  18. #define PM prompt
  19. #define LI lineinput
  20. #define JH_CK 500
  21. #define JH_ExtHK 15
  22.  
  23.  
  24. #define ADDBIT 1000
  25. #define REMBIT 1001
  26. #define QUERYBIT 1002
  27. extern void end(void);
  28. extern void LastCommand(void);
  29. extern void main(int,char argv[]);
  30. struct User {
  31.  char    Name[31],Pass[9],Location[30],PhoneNumber[13];
  32.  USHORT  Slot_Number;
  33.  USHORT  Sec_Status,
  34.      Sec_Board,                   /* File or Byte Ratio */
  35.      Sec_Library,                 /* Ratio              */
  36.      Sec_Bulletin,                /* Computer Type      */
  37.      Messages_Posted;
  38.  /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
  39.  ULONG   NewSinceDate, ConfRead1, ConfRead2, ConfRead3, ConfRead4,
  40.          ConfRead5;
  41.  UWORD   XferProtocol, Filler2;
  42.  UWORD   Lcfiles,BadFiles; 
  43.  ULONG   AccountDate;
  44.  UWORD   ScreenType, Filler1;
  45.  char    Conference_Access[10];
  46.  USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
  47.  long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
  48.  ULONG   Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
  49.  char    Expert;
  50.  ULONG   ConfYM1, ConfYM2, ConfYM3, ConfYM4, ConfYM5, ConfYM6, ConfYM7,
  51.          ConfYM8, ConfYM9;
  52.  long    BeginLogCall;
  53.  UBYTE   Protocol, UUCPA, LineLength, New_User;
  54.  };
  55.  
  56. ULONG UnixTimeOffset = 252482400;
  57.  
  58. struct MsgPort *port;
  59. struct MsgPort *replymp;
  60. struct JHMessage *Jhmsg,*msg;
  61. #define ANYKEY "press <RETURN> to continue"
  62. char PortName[20];
  63. VOID Register(int node)
  64. {
  65.   ULONG portsig;
  66.   int n1,n2,n3;
  67.   int found=0;
  68.   Jhmsg=(struct JHMessage *)AllocMem(sizeof(struct JHMessage),MEMF_CLEAR|MEMF_PUBLIC);
  69.  
  70.  if(Jhmsg==0)
  71.   {
  72.      printf("Not enough Memory for message structure\n");
  73.      exit(30);
  74.   }
  75.   replymp=CreatePort(0L,0L); //strcpy(PortName,DoorReply);
  76.   
  77.  
  78.   if(replymp==0)
  79.   {
  80.     printf("Couldn't create reply port\n");
  81.     FreeMem(Jhmsg,sizeof(struct JHMessage));
  82.     exit(30);
  83.   }
  84.   Jhmsg->Msg.mn_Node.ln_Type=NT_MESSAGE;
  85.   Jhmsg->Msg.mn_Length=sizeof(struct JHMessage);
  86.   Jhmsg->Msg.mn_ReplyPort=replymp;
  87.   strcpy(Jhmsg->String,"");
  88.   Jhmsg->Command=JH_REGISTER;
  89.   Jhmsg->Data=2;
  90.   Jhmsg->NodeID=-1;
  91.   Jhmsg->LineNum=0;
  92.   sprintf(PortName,"AEDoorPort%d",node);
  93.   while(!(port=FindPort(PortName)));
  94.   PutMsg(port,(struct Message *)Jhmsg);
  95.  
  96.     portsig=1<<replymp->mp_SigBit;
  97.   
  98. Wait(portsig);
  99. msg=(struct JHMessage *)GetMsg((struct MsgPort *)replymp);
  100. }
  101.  
  102. VOID ShutDown(VOID)
  103. {
  104.  ULONG portsig,signal;
  105.   LastCommand();
  106.  portsig=1<<replymp->mp_SigBit;
  107.   Jhmsg->Command=JH_SHUTDOWN;
  108.   PutMsg(port,(struct Message *)Jhmsg); 
  109.   signal=Wait(portsig);
  110.   ClosePort();
  111. }
  112.  
  113. void ClosePort(void)
  114. {
  115.       while(msg=(struct JHMessage *)GetMsg((struct MsgPort *)replymp));
  116.        DeletePort((struct MsgPort *)replymp);
  117.        FreeMem(Jhmsg,sizeof(struct JHMessage));
  118. }
  119.  
  120. void sendmessage(char mstring[],int nl)
  121. {
  122.         register int counter;
  123.         char Temp[80];
  124.    
  125.         if(strlen(mstring)<80) sendMessage(mstring,0);
  126.         else
  127.         {
  128.           counter=0;
  129.           do
  130.           {
  131.             sprintf(Temp,"%.79s",&mstring[counter]);
  132.             sendMessage(Temp,0);
  133.             counter +=79;
  134.           }while(strlen(Temp)==79);
  135.         }
  136.         if(nl==1){ sendMessage("",1); Jhmsg->LineNum +=1; }
  137.         if(Jhmsg->LineNum==22)
  138.         { hotkey(ANYKEY,Temp); 
  139.  SM("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b",0);
  140. SM("                          ",0);
  141. SM("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b",0);
  142. }
  143. }
  144.  
  145. void sendMessage(char mstring[],int nl)
  146. {
  147.     Jhmsg->Data = nl;
  148.     Jhmsg->Command = JH_SM;
  149.     strcpy(Jhmsg->String,mstring);
  150.     PutMsg(port,(struct Message *)Jhmsg);
  151.     (void)WaitPort(replymp);
  152.     (void)GetMsg(replymp);
  153. }
  154. void hotkey(char mstring[],char *ostring)
  155. {
  156.         Jhmsg->LineNum=0;
  157.     strcpy(Jhmsg->String,mstring);
  158.     Jhmsg->Command = JH_HK;
  159.     PutMsg(port,(struct Message *)Jhmsg);
  160.     (void)WaitPort(replymp);
  161.     (void)GetMsg(replymp);
  162.     strcpy(ostring,Jhmsg->String);
  163. if(Jhmsg->Data==-1) CloseOut();
  164. }
  165.  
  166. void getuserstring(char *ostring,int nl)
  167. {
  168.         Jhmsg->Command = nl;
  169.         Jhmsg->Data=READIT;
  170.     PutMsg(port,(struct Message *)Jhmsg);
  171.     (void)WaitPort(replymp);
  172.     (void)GetMsg(replymp);
  173.    strcpy(ostring,Jhmsg->String);
  174. }
  175. void putuserstring(char *ostring,int nl)
  176. {
  177.         Jhmsg->Command = nl;
  178.         Jhmsg->Data=WRITEIT;
  179.         strcpy(Jhmsg->String,ostring);
  180.     PutMsg(port,(struct Message *)Jhmsg);
  181.     (void)WaitPort(replymp);
  182.     (void)GetMsg(replymp);
  183.  
  184. }
  185. VOID CloseOut(void)
  186. {
  187.   ShutDown();
  188.   end();
  189. }
  190.  
  191. int Get_ConfName(APTR n,APTR l,int num)
  192. {
  193.      char *s;
  194.      strcpy((char *)n,"");
  195.      Jhmsg->Command = GET_CONFNUM;
  196.      Jhmsg->Data=num;
  197.      Jhmsg->Filler1=n;
  198.      Jhmsg->Filler2=l;
  199.     PutMsg(port,(struct Message *)Jhmsg);
  200.     (void)WaitPort(replymp);
  201.     (void)GetMsg(replymp);
  202.      s=(char *)n;
  203.      if(*s=='\0') return(0);
  204.      return(1);
  205. }
  206.